package com.example.controller;

import com.example.result.EmployeeResult;
import com.example.result.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpSession;

/** 控制器类的基类 */
public class BaseController {
    //获取session中员工的id
    public Long getSessionId(HttpSession session){
        EmployeeResult employeeResult=(EmployeeResult)session.getAttribute("employee");
        return employeeResult.getId();
    }
    //获取session中员工的username
    public String getSessionUsername(HttpSession session){
        EmployeeResult employeeResult=(EmployeeResult)session.getAttribute("employee");
        return employeeResult.getUsername();
    }
    //获取session中员工的username
    public String getSessionName(HttpSession session){
        EmployeeResult employeeResult=(EmployeeResult)session.getAttribute("employee");
        return employeeResult.getName();
    }
    //获取session中员工的employee
    public EmployeeResult getSessionUser(HttpSession session){
        EmployeeResult employeeResult=(EmployeeResult)session.getAttribute("employee");
        return employeeResult;
    }
}
